package com.main;

import com.util.Constant;
import com.util.GameUtil;

import java.awt.*;
import java.awt.image.BufferedImage;

public class GameBackGround {
    //    存放背景图片
    private BufferedImage bkimg;
//    构造器初始化参数

    public GameBackGround() {
        bkimg = GameUtil.loadBufferedImage(Constant.BK_IMG_OATH);
    }

    //    绘制图片
    public void draw(Graphics g) {
//        得到图片的宽度和高度
        int height = bkimg.getHeight();
        int weight = bkimg.getWidth();
//        所需要的图片张数
        int count = Constant.FRAM_WIDTH / weight + 1;
        for (int i = 0; i < count; i++) {
            g.drawImage(bkimg, weight * i, Constant.FRAM_HEIGHT - height, null);
        }
    }
}
